package com.dzj.exam.mapper;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.dzj.exam.entity.Question;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.dzj.exam.vo.QuestionQueryVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * 题目Mapper接口
 * 继承MyBatis Plus的BaseMapper，提供基础的CRUD操作
 */
public interface QuestionMapper extends BaseMapper<Question> {

    /**
     * 获取每个分类的题目数量
     * @return 包含分类ID和题目数量的结果列表
     */
    @Select("SELECT category_id, COUNT(*) as count FROM questions where is_deleted = 0  GROUP BY category_id ; ")
    List<Map<Long, Object>> getCategoryQuestionCount();

    /**
     * 分页查询题目信息，第一步！一会要触发，根据题目id查询选项！！
     * @param page 分页对象
     * @param questionQueryVo 自己实体类,封装的查询对象！
     * @return
     */
    IPage<Question> customPage(IPage page, @Param("queryVo") QuestionQueryVo questionQueryVo);

    Question customGetById(Long id);

    List<Question> customQueryQuestionListByPaperId(Integer id);
}